# routes/predict_api.py

from fastapi import APIRouter, HTTPException
from pydantic import BaseModel
from typing import Dict
from service.predictor_service import predict_by_model

router = APIRouter()

class PredictRequest(BaseModel):
    model: str
    features: Dict[str, float]

@router.post("/predict")
def predict(request: PredictRequest):
    try:
        result = predict_by_model(request.model, request.features)
        return result
    except ValueError as e:
        raise HTTPException(status_code=400, detail=str(e))
